<template>
  <panel>

    <el-row class="operate-wrap">
      <el-col :span="30">
        <el-button type="info" size="small" @click="editForm">保存</el-button>
        <el-button size="small" @click="cancelForm">取消</el-button>
      </el-col>
    </el-row>

    <el-row class="operate-wrap">
      <h3 class="mt24" style="text-align:left">基本信息</h3>
    </el-row>

    <el-row>
      <el-col :span="24" class="form-wrap">
        <el-form :model="ruleForm"  ref="ruleForm" label-width="100px" :label-position="'left'">
          <el-col :span="24" >
            <el-form-item label="项目备案名" prop="caseName" class="item-5">
              <el-input v-model="ruleForm.caseName" size="small" placeholder="请输入营销备案名"></el-input>
            </el-form-item>
          </el-col>
          <el-form-item label="组织结构" prop="oName" class="item-5">
            <el-input v-model="ruleForm.oName" size="small" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="法人公司" prop="companyCode" class="item-5">
            <el-input v-model="ruleForm.cName" size="small" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="项目名称" prop="name" class="item-5">
            <el-input v-model="ruleForm.name" size="small" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="项目编码" prop="code" class="item-5">
            <el-input v-model="ruleForm.code" size="small" :disabled="true"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

    <el-row class="operate-wrap">
      <h3 class="mt24" style="text-align:left">属性信息</h3>
    </el-row>

    <el-row>
      <el-col :span="24" class="form-wrap">
        <el-form :model="ruleForm"  ref="ruleForm" label-width="100px" :label-position="'left'">
          <el-form-item label="别名/曾用名" prop="alias" class="item-5">
            <el-input v-model="ruleForm.alias" size="small" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="项目负责人" prop="responsible" class="item-5">
            <el-input v-model="ruleForm.responsible" size="small" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="管理模式" prop="managementModel" class="item-5">
            <el-input v-model="ruleForm.mName" size="small" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="合作方" prop="partner" class="item-5">
            <el-input v-model="ruleForm.partner" size="small" :disabled="true" ></el-input>
          </el-form-item>
          <el-form-item label="项目纬度" prop="latitude" class="item-5">
            <el-input v-model="ruleForm.latitude" size="small" :disabled="true" ></el-input>
          </el-form-item>
          <el-form-item label="我方权益比" prop="share" class="item-5">
            <el-input v-model="ruleForm.share" size="small" :disabled="true" ></el-input>
          </el-form-item>
          <el-form-item label="项目经度" prop="longitude" class="item-5">
            <el-input v-model="ruleForm.longitude" size="small" :disabled="true" ></el-input>
          </el-form-item>
          <el-col :span="24">
          <el-form-item label="项目地址" prop="address" class="item-10">
            <el-input v-model="ruleForm.address" size="small" :disabled="true" ></el-input>
          </el-form-item>
          </el-col>
        </el-form>
      </el-col>

    </el-row>
  </panel>

</template>


<script>


  import {queryProjectHeadById,editProjectHead} from "@/api/project";

  export default {

    data() {
      return {

        ruleForm: {
          orgnazationId: '',
          companyCode: '',
          name: '',
          code: '',
          address:'',
          caseName:'',
          alias:'',
          responsible:'',
          managementModel:'',
          partner:'',
          latitude:'',
          share:'',
          longitude:'',
          cName:'',
          oName:''
        },
      }
    },


    mounted:function(){
      const _this = this;
      let id = _this.$route.params.id;
      this.initForm(id);
    },


    methods: {

      /**
       * 保存项目详细信息
       */
      editForm(){
        const _this = this;
        let id = _this.$route.params.id;
        if(_this.ruleForm.caseName==''||_this.ruleForm.caseName==undefined){
          _this.$message('项目备案名为空!');
        }else{
          let obj = {
            "projectHead": {
              "id":id,
              "caseName":_this.ruleForm.caseName,
            }
          };
          editProjectHead(obj).then((res) => {
            if (res != null) {
              _this.$message('修改成功!');
              _this.$router.push({path: '/house/info'});
            }
          }).catch(function (error) {
            _this.$message('保存失败!');
          });
        }
      },


      /**
       * 取消跳转到项目信息页面
       */
      cancelForm(){
        this.$router.push({path: '/house/info'});
      },


      /**
       * 初始化项目详细信息
       */
      initForm(id){
        const _this = this;
        let obj = {
          "position":"project_queryProjectHeadBySearch",
          "paramMap":{
            "id":id,
          },
        }
        queryProjectHeadById(obj).then((res) => {
          if(res!=undefined) {
            _this.ruleForm = res[0];
          }
        })
      }





    }
  }
</script>

<style>

</style>
